<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            outline: 0; 
            /* input a button img 
            ios android  移动端 webkit 统一了
            浏览器轮廓不统一 webkit(浏览器内核，开源)-chrome(商业) ie 等 */
        }
        body {
            color: #111;
        }
        a {
            text-decoration: none;
            color: inherit; /* 继承 */
            
        }
        .pj_tabbar {
            display: flex;
        }
        .pj_tababbar__item {
            flex: 1;
            height: 50px;
            border-bottom: 1px solid #ddd;
        }
        .pj_tababbar__item a {
            display: block;
            line-height: 50px;
            text-align: center;
        }
        .pj_tababbar__item a:first-child {
            border-right: 1px solid #ddd;
        }
        .pj_tababbar__item_on {
            background-color: pink;
            color: white;
        }
    </style>
</head>
<body>
    <!-- 手感 -->
    <div class="pj_tabbar">
        <div class="pj_tababbar__item pj_tababbar__item_on">
            <a href="#" data-type="basic">basic</a>
        </div>

        <div class="pj_tababbar__item">
            <a href="#" data-type="super">super</a>
        </div>
    </div>
    <div id="list">

    </div>
    <script>
        const list = document.getElementById('list');
        const links = document.querySelectorAll('.pj_tababbar__item a');
        // const tabTypes = {
        //     basic: Symbol(), // ES6 里新的简单数据类型， 独一无二的
        //     super: Symbol()
        // }
        // java 等大型语言，tab切换时，为了可读性 tabTypes对象常量
        // 所以tab类型的管理  统一在一个地方
        const tabTypes = {
            basic: 'basic',
            super: 'super'
        }
        links.forEach(link => {
            link.addEventListener('click', function(event) {
                // a 带来交互感
                event.preventDefault(); // 阻止默认跳转行为
                const type = event.target.dataset.type;
                const parent = this.parentNode;
                console.log(parent,'11111')
                if (!parent.classList.contains('pj_tababbar__item_on')) {
                    document.querySelector('.pj_tababbar__item_on')
                        .classList.remove('pj_tababbar__item_on');
                    parent.classList.add('pj_tababbar__item_on');
                }
                // if (type == 'basic') {
                if (type == tabTypes.basic) {
                    console.log('-------')
                    list.innerText = 'basic'
                }
                if (type == tabTypes.super) {
                    console.log('++++++++')
                    list.innerText = 'super'
                }
            })
        })
    </script>
</body>
</html>